<?
/**
* Copyright (c) 2002-2007 BioWare Corp.
* http://www.bigdaddymonitor.org
*
* This file is part of the BigDaddy Monitoring
* program. It is free software distributed under
* the terms of the BSD License. It is ditributed
* in the hopes that it will be useful, but
* WITHOUT ANY WARRANTY; without event the implied
* warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.
*
* The BSD License is available from:
* http://www.opensource.org/licenses/bsd-license.php
**/

$aIncident = $BigDaddyData->GetIncidentByID($_REQUEST["ID"]);
$aAffectedServers = $BigDaddyData->GetServersByIncidentID($_REQUEST["ID"]);
$aComments = $BigDaddyData->GetCommentsByIncidentID($_REQUEST["ID"]);

$nComments = 0;

if (is_array($aComments))
{
	$nComments = count($aComments);
}


include_once(CLASS_FORMATTINGPARSE);
$WikiFormat = new FormattingParse();

?>
<p class="sectiontitle">Incident: <?=$aIncident["title"];?></p>
<p>Start: <?=get_time_str($aIncident["incidentStart"], 1);?><br>
End: <?=get_time_str($aIncident["incidentEnd"], 1);?><br>
Originally Posted By <b><?=$aIncident["postedBy"];?></b> On <?=get_time_str($aIncident["postedTime"], 1);?><br><br>
There are <a href="#comments"><?=$nComments;?></a> Comments.
</p>


<?
if (is_array($aAffectedServers))
{
	?>
	<p class="sectiontitle">Affected Servers</p>
	
	<ul>
	<?
	foreach ($aAffectedServers as $aRow)
	{
		?>
		<li><a href="/index.html?page=ServerViewDetails&serverID=<?=$aRow["serverID"];?>"><?=$aRow["hostname"];?></a></li>
		<?
	}
	?>
	</ul>
	<?
}
?>


<p class="sectiontitle">Description ("What went wrong?")</p>

<?=$WikiFormat->ParseFormatting($aIncident["description"]);?>

<p class="sectiontitle">Reasons ("Why?")</p>

<?=$WikiFormat->ParseFormatting($aIncident["reasons"]);?>

<p class="sectiontitle">Follow Up ("What next?")</p>

<?=$WikiFormat->ParseFormatting($aIncident["followup"]);?>

<?
if (is_array($aComments))
{
	?>
	<a name="comments"></a>
	<p class="sectiontitle">Comments</p>
	
	<?
	foreach ($aComments as $aRow)
	{
		?>
		<div class="commentblock">
		<span class="fromheader"><?=$aRow["postedBy"];?> (<?=get_time_str($aRow["postedTime"], 1);?>)
		<?
		
		if ($aRow["postedBy"] == LOGGEDIN_USERNAME || $BigDaddy->IsUserAllowedByAction("incident-admin"))
		{
			?>
			<a href="?page=EditComment&incidentID=<?=$aRow["incidentID"];?>&commentID=<?=$aRow["ID"];?>">edit</a> |
			<a href="query_incident.php?action=deletecomment&incidentID=<?=$aRow["incidentID"];?>&commentID=<?=$aRow["ID"];?>">delete</a>
			<?
		}
		?>
		
		</span>
		
		<?=$WikiFormat->ParseFormatting($aRow["comment"]);?>

	
		</div>
		<?
	}
	
}
?>
